void STOCK_init(U32 cubeSize, U32 nbElements)
{
	cubeStock = malloc(nbElements*cubeSize);
	stockCubeSize = cubeSize;
	writeIndex = 0;
	readIndex = 0;
} 

void STOCK_append(void* cube)
{
	void* location = (void*) ((BYTE*)cubeStock + stockCubeSize * writeIndex);
	memcpy(location,cube,stockCubeSize);
	writeIndex++;
	
}

void* STOCK_readNext()
{
	return (void*) ((BYTE*)cubeStock + stockCubeSize * readIndex);
}

void* STOCK_writeNext()
{

	void* tmp = (void*) ((BYTE*)cubeStock + stockCubeSize * writeIndex);
	return tmp;
}

void STOCK_ReadIncrement()
{
	readIndex++;
}

void STOCK_WriteIncrement()
{
	writeIndex++;
}

BOOL STOCK_isEmpty()
{
	return readIndex >= writeIndex;
}